/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package holidaysManager;

import app.Global;
import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import lib.JButtonTable.ButtonEditor;

/**
 *
 * @author yoshi
 */
public class DeleteButtonEditor extends ButtonEditor{

    HolidaysManagerDefault myView;
    
    public DeleteButtonEditor(JCheckBox checkBox, HolidaysManagerDefault myView) {
        super(checkBox);
        this.myView = myView;
    }
    
    @Override
    protected void fireEditingStopped() {
        super.fireEditingStopped();
        if(JOptionPane.showConfirmDialog(Global.getFrame(), "Are you sure to delete this holiday?", "Delete confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
            myView.getMyController().delete(((DeleteButtonModel)this.getCellEditorValue()).getHoliday());
        };
        
    }
}
